#include "SystemInfo.h"

namespace MC500{

    std::string ConvertSize(uint64_t size, uint8_t unit) {
        if (size < 1024) {
            std::ostringstream stream;
            stream << size;
            switch (unit) {
            case 0:
                stream << 'B';
                break;
            case 1:
                stream << 'K';
                break;
            case 2:
                stream << 'M';
                break;
            case 3:
                stream << 'G';
                break;
            case 4:
                stream << 'T';
                break;
            default:
                stream << '?';
            }
            return stream.str();
        }
        return ConvertSize(size >> 10, ++unit);
    }

class WindowsSystemInfo : public SystemInfo{
    public:
        virtual uint64_t GetPhyMem(void){
            return 3000;
        }
        virtual uint64_t GetPhyMemUsed(void){
            return 2000;
        }

        virtual uint8_t GetCPUUsed(void){
            return 89;
        }
        virtual DateTime GetDateTime(){
            DateTime date = {2020,1,30,18,5,11};
            return date;
        }
        virtual DateTime GetStableRunningTime(){
            DateTime date = {2020,1,30,18,5,11};
            return date;
        }
        virtual TrifficInfo GetTrifficInfo() {
            return TrifficInfo(5000, 60000);
        }

        uint8_t GetDiskUsage() override {
            return 81;
        }

};

SystemInfo* SystemInfo::_ins = nullptr;

SystemInfo* SystemInfo::GetInstance(){
    if(_ins == nullptr){
        _ins = new WindowsSystemInfo();
    }
    return _ins;
}

}